import { PORT1 } from "@/api/config/servicePort";
import Http from "@/api/index";

const baseUrl = PORT1 + "/cloud/file";

export const createDir = (params: any) => {
  return Http.post(PORT1 + "/system/upload/create_dir", params);
};

export const getRoot = () => {
  return Http.get(PORT1 + "/system/upload/root");
};

export const editDir = (params: any) => {
  return Http.put(PORT1 + "/system/upload/edit_dir", params);
};

// export const uploadFile = (params: FormData, query: any) => {
//   return Http.post(PORT1 + "/system/upload/upload_file?pid=" + query, params, { noLoading: true });
// };

export const uploadFile = (params: FormData, query: any) => {
  return Http.post(baseUrl + "/upload?pid=" + query, params, { noLoading: true });
};

export const getFileList = (params: any) => {
  return Http.get(baseUrl + "/list", params);
};

// 修改文件名称
export const edit = (params: any) => {
  return Http.put(baseUrl + "/edit", params);
};

export const getSingleFile = (params: any) => {
  return Http.get(PORT1 + "/system/upload/get_single", params);
};

export const setCover = (params: any) => {
  return Http.post(baseUrl + "/set_cover", params);
};

export const deleteFile = (params: any) => {
  return Http.post(baseUrl + "/delete", params);
};

export const getCapacity = () => {
  return Http.get(baseUrl + "/capacity");
};
